package day11.tarena.com;
//解决大数字（超过long）/double的精度问题
import java.math.BigDecimal;
public class TestDouble {
		public static void main(String[] args) {
			double d1 =1.0;
			double d2 = 0.41;
			System.out.println("double:"+(d1-d2));
			BigDecimal bd1 = new BigDecimal(d1);
			BigDecimal bd2 = new BigDecimal(d2);
			double result = bd1.subtract(bd2).doubleValue();
			System.out.println("r1:"+result);
			BigDecimal bd3 = new BigDecimal(d1+"");
			BigDecimal bd4 = new BigDecimal(d2+"");
			double result2 =bd3.subtract(bd4).doubleValue();
			System.out.println("r2:"+result2);
			
			BigDecimal bd5 = new BigDecimal("1");
			BigDecimal bd6 = new BigDecimal("4");
			double d = bd5.divide(bd6,1,BigDecimal.ROUND_HALF_UP).doubleValue();
			System.out.println(d);
			
		}

}
